package cn.topcodes.tcsf.admin.scheduling;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.ApplicationListener;
import org.springframework.context.event.ContextRefreshedEvent;

public class StartQuartzListener implements ApplicationListener<ContextRefreshedEvent> {

    @Autowired
    private ScheduleServiceImpl scheduleService;

    @Override
    public void onApplicationEvent(ContextRefreshedEvent event) {
        if(event.getApplicationContext().getParent() == null) {
            scheduleService.start();
        }
    }
}